<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../inc.jsp"></jsp:include>
    <title>待出票查询页面</title>
   <%--  <script src="${ctx}/js/iconfont.js"></script> --%>
    <link rel="stylesheet" href="${ctx}/css/page.css"/>
    <link rel="stylesheet" href="${ctx}/css/iconfont.css"/>
    <style>
    	.conTable{
    		margin-top:10px;
    	}
    	
    </style>
    <script type="text/javascript">
        $(function(){
            //点击查询 重新加载列表
            $("#query").click(function(){
                pageNum = 1;
                getData();
            });
            getData();
        })
        var pageNum = 1;
        function getData(){
            //出发到达城市清空处理
            alsoempty($("#homecity_name"),$("#_startCity"));
            alsoempty($("#getcity_name"),$("#_endCity"));
            //获取参数
            var orderNumber=$("#_orderNumber").val();
            var toStartAirportCode=$("#_startCity").val();
            var toEndAirportCode=$("#_endCity").val();
            var toStartDate=$("#startDate").val();
            var toEndDate=$("#endDate").val();
            if(typeof(toStartAirportCode) == 'undefined'){
                toStartAirportCode = "";
            };
            if(typeof(toEndAirportCode) == 'undefined'){
                toEndAirportCode = "";
            };
            var param = {
                "orderNumber":orderNumber,
                "toStartAirportCode":toStartAirportCode,
                "toEndAirportCode":toEndAirportCode,
                "toStartDate":toStartDate,
                "toEndDate":toEndDate,
                "page":pageNum,
                "rows":20
            }
            $.get('${ctx}/search/getBuyerList?orderStatus=2&temp='+Math.random(),param,function(data){
                $('table tbody').empty();
                var str = "";
                for(var i=0;i<data.rows.length;i++){
                    var obj = data.rows[i];
                    var intervalDay=CommonConverter.toEmptyStr(obj.list[0].intervalDay);
                    if(intervalDay != 0){
                        intervalDay ="+"+intervalDay;
                    };
                    str+="<tr class='reBorder' height='40px'>"
                    str+="	<td colspan='7'>"
                    str+="		<span class='orderNumberSpan'>订单号："+obj.orderNumber+"</span>"
                    str+="	</td>"
                    str+="	<td align='center'>"
                    if(obj.dayFlay){
                    	//str+='<svg class="icon position" onclick=link("'+obj.orderNumber+'") aria-hidden="true"><use xlink:href="#icon-bianji"></use></svg>';
                    	str +='<i class="icon iconfont" title="编辑" onclick=link("'+obj.orderNumber+'")>&#xe601;</i>';
                    };
                    str+="	</td>"
                    str+="</tr>"
                    str+="<tr height='90px'>"
                    str+="	<td align='center'>"
                    str+="		往：<span style='color:black;'>"+obj.list[0].airlineNumber+"</span><br/>"
                    str+= (obj.list.length==2) ?  "返：<span style='color:black;'>"+obj.list[1].airlineNumber+"</span>" :  "";
                    str+="	</td>"
                    str+="	<td align='right'>"
                    str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].deptTime)+"</span><br/>"
                    str+="		<span style='color:#444e50'>"+obj.list[0].deptCity+"</span><span style='color:#444e50'>("+obj.list[0].deptCode+")</span><span style='color:#e2615c'>"+obj.list[0].deptTerminal+"</span><br/>"
                    str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].arrTime)+"</span><br/>" :  "";
                    str+="	</td>"
                    str+="	<td align='center'>"
                    str+="		<span style='color:#23b9dc'>"+obj.list[0].deptDate+"</span><br/>"
                    str+= (obj.list.length==2) ?  "<img src='${ctx}/image/flightQuery/round.gif'><br/>" :  "<img src='${ctx}/image/flightQuery/dancheng.png'><br/>";
                    str+= (obj.list.length==2) ?  "<span style='color:#23b9dc'>"+obj.list[1].deptDate+"</span><br/>" :  "";
                    str+="	</td>"
                    str+="	<td>"
                    str+="		<span>"+CommonConverter.formatFlightTime((obj.list)[0].arrTime)+"</span><span style='color:#e2615c;'>"+intervalDay+"</span><br/>"
                    str+="		<span style='color:#444e50'>"+obj.list[0].arrCity+"</span><span style='color:#444e50'>("+obj.list[0].arrCode+")</span><span style='color:#e2615c'>"+obj.list[0].arrTerminal+"</span><br/>"
                    str+= (obj.list.length==2) ?  "<span>"+CommonConverter.formatFlightTime((obj.list)[1].deptTime)+"</span><br/>" :  "";
                    str+="	</td>"
                    str+="	<td width='88px' align='center'>"+CommonConverter.toEmptyString(obj.sellingPrice)+"</td>"
                    str+="	<td width='86px' align='center'>"+CommonConverter.toEmptyString(obj.purchQuantity)+"</td>"
                    str+="	<td width='96px' align='center' style='color:black'>"+CommonConverter.toEmptyString(obj.sum)+"</td>"
                    str+="	<td width='151px' align='center' style='color:#e2615c'>待出票</td>"
                    str+="</tr>"
                }
                $('#tb').append(str);
                //显示分页
                layui.use(['laypage', 'layer'], function(){
                    var laypage = layui.laypage;
                    laypage({
                        cont: 'pager'
                        ,pages:  Math.ceil(data.total/20) //得到总页数 //总页数
                        ,groups: 5 //连续显示分页数
                        ,skin: '#1E9FFF'
                        ,curr : pageNum
                        ,jump: function(obj,first){
                            if(!first){
                                pageNum = obj.curr;
                                getData();
                            }
                        }
                    });
                });
            })
        }
        //如果为空  对应的文本框为空
        function alsoempty(a,b){
            if(a.val() == "中文/拼音"){
                b.val("");
            };
        };
        //修改旅客信息
        function link(orderNumber){
        	var url='${ctx}/np/toEditPassengerInfo/'+orderNumber;
        	window.location.href=url;
        };
    </script>
</head>
<body>
<jsp:include page="../head.jsp"/>
<div class="content">
         <ul class="list">
             <li>订单号：<input style='width:120px;height:18px' id="_orderNumber" /></li>
             <li>出发城市：
                 <input type="text" value="" size="15" id="homecity_name" name="homecity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel" mod_address_suggest="" mod_address_reference="_startCity" mod_notice_tip="中文/拼音" />
                 <input id="_startCity" name="_startCity" type="hidden" value="" />
             </li>
             <li>到达城市：
                 <input type="text" value="" size="15" id="getcity_name" name="getcity_name" style="width:150px;height: 18px" mod="address|notice" mod_address_source="hotel"  mod_address_reference="_endCity" mod_notice_tip="中文/拼音" />
                 <input id="_endCity" name="_endCity" type="hidden" value="" />
             </li>
             <li> 出发时间 ：
               <input type="text" id="startDate" class="Wdate"  value="${requestScope.deptDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'%y-%M-\#{%d+2}',maxDate:'#F{$dp.$D(\'endDate\')}'*/})"/>
				&nbsp;&nbsp;&nbsp;&nbsp;
				至<input type="text" id="endDate" class="Wdate"  value="${requestScope.endDate}" onFocus="new WdatePicker({dateFmt:'yyyy-MM-dd'/*,minDate:'#F{$dp.$D(\'startDate\')}'*/})">
             <li>
             <li class="right"><button class='query' id="query">查询</button></li>
         </ul>
   		 <table class="conTable">
				<thead>
					<tr height="38" >
						<td width="165" align="center"><img src="${ctx}/image/flightQuery/flightNumber.gif">航班号</td>
						<td width="241" align="right"><img src="${ctx}/image/flightQuery/flightStart.gif">出发</td>
						<td width="157" align="center">&nbsp;&nbsp;&nbsp;</td>
						<td width="241"><img src="${ctx}/image/flightQuery/flightEnd.gif">到达</td>
						<td width="117" align="center"><img src="${ctx}/image/price.gif">单价</td>
						<td width="115" align="center"><img src="${ctx}/image/amount.gif">数量</td>
						<td width="129" align="center"><img src="${ctx}/image/price.gif">实际支付</td>
						<td width="135" align="center"><img src="${ctx}/image/status.gif">状态</td>
					</tr>
				</thead>
				<tbody id="tb">

				</tbody>
			</table>
			<!-- 分页 -->
        	<div id="pager" class="divBox"></div>
</div>
<script type="text/javascript" src="${ctx }/jslib/airport/fixdiv.js"></script>
<script type="text/javascript" src="${ctx }/jslib/airport/address.js"></script>
<jsp:include page="../footer.jsp"/>
</body>
</html>